home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / ARexxTools / fpl70.lha / src / script.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-08  |  40.2 KB  |  1,225 lines

  1. /******************************************************************************
  2.  *                   FREXX PROGRAMMING LANGUAGE                  *
  3.  ******************************************************************************
  4.  
  5.  Script.h
  6.  
  7.  Script structures and defines!
  8.  
  9.  *****************************************************************************/
  10.  
  11. /************************************************************************
  12.  *                                                                      *
  13.  * fpl.library - A shared library interpreting script langauge.         *
  14.  * Copyright (C) 1992-1994 FrexxWare                                    *
  15.  * Author: Daniel Stenberg                                              *
  16.  *                                                                      *
  17.  * This program is free software; you may redistribute for non          *
  18.  * commercial purposes only. Commercial programs must have a written    *
  19.  * permission from the author to use FPL. FPL is *NOT* public domain!   *
  20.  * Any provided source code is only for reference and for assurance     *
  21.  * that users should be able to compile FPL on any operating system     *
  22.  * he/she wants to use it in!                                           *
  23.  *                                                                      *
  24.  * You may not change, resource, patch files or in any way reverse      *
  25.  * engineer anything in the FPL package.                                *
  26.  *                                                                      *
  27.  * This program is distributed in the hope that it will be useful,      *
  28.  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
  29.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                 *
  30.  *                                                                      *
  31.  * Daniel Stenberg                                                      *
  32.  * Ankdammsgatan 36, 4tr                                                *
  33.  * S-171 43 Solna                                                       *
  34.  * Sweden                                                               *
  35.  *                                                                      *
  36.  * FidoNet 2:201/328    email:dast@sth.frontec.se                       *
  37.  *                                                                      *
  38.  ************************************************************************/
  39.  
  40. #define OUTDATE_OLD /* to outdate the old error enums! */
  41.  
  42. #include <string.h>
  43. #include "FPL.h"
  44. #if defined(AMIGA) && defined(SHARED)
  45. #include "LibAlloc.h" /* stack allocation routines */
  46. #endif
  47.  
  48. /**********************************************************************
  49.  *
  50.  * Global defines:
  51.  *
  52.  *********************************************************************/
  53.  
  54. #ifndef  TRUE
  55. #define  TRUE    1
  56. #endif
  57. #ifndef  FALSE
  58. #define  FALSE    0
  59. #endif
  60.  
  61. #define FPLTEXT_UNKNOWN_PROGRAM "<unknown program>"
  62. /* When requesting the name of a program, and no program is available or no
  63.    name has been given. This string will be returned! */
  64.  
  65. #define MAX_DIMS         40  /* Maximum number of array dimensions */
  66. #define IDENTIFIER_LEN       64
  67. /* maximum number of characters in a function-, variable- or label name
  68.    ANSI C Standard X3J11 states that there should be at least "31
  69.    significant initial characters in an internal identifier or a macro name" */
  70. #define ADDSTRING_DEFAULT     16  /* default length of a string expression */
  71. #define ADDSTRING_INC         63  /* string expression length increase step */
  72. #define MAX_ARGUMENTS         63 /* Maximum number of function arguments */
  73.  
  74. #define FPL_HASH_SIZE 67
  75. /* Default hash table size. This should not be dividable with 2, 3, 4 or 5 */
  76.  
  77. #define FPL_MIN_HASH 10
  78. /* The smallest acceptable hash table size */
  79.  
  80. #define BUF_SIZE (IDENTIFIER_LEN+3) /* "global" FPL buffer size */
  81.  
  82. #define FPL_STRVARARG     'C'
  83. #define FPL_INTVARARG     'N'
  84. #define FPL_STRVARARG_OPT (FPL_STRVARARG^32)
  85. #define FPL_INTVARARG_OPT (FPL_INTVARARG^32)
  86. #define FPL_VOIDARG       'V'
  87. /* Internal return code symbol for `void' functions. In all ways they act as
  88.    `int' functions, and they can in fact even return ints!!! */
  89.  
  90. #if defined(AMIGA) && defined(SHARED)
  91. #define FPL_MIN_STACK 8000  /* smallest required stack */
  92. #define FPL_MAX_STACK 20000 /* maximum stack left after a run */
  93. #define FPL_MAX_LIMIT 40000 /* default maximum stack use possible */
  94.  
  95. #define FPLSTACK_MINIMUM 1000 /* Stack margin. When the stack space is below,
  96.                  this, than realloc to a bigger one! */
  97. #endif
  98.  
  99. #define BLOCK_ENTRIES 16    /* Number of free-block entries in the
  100.                    free-block array */
  101. #define MEMORY_QUEUE_SIZE 20    /* number of free blocks in the queue */
  102.  
  103. #define MEMORY_QUEUE    1    /* Yes, we'll use the memory queuing system! */
  104.  
  105. #define ALLOCBIT    (1<<31) /* set if MALLOC_STATIC */
  106. #define SIZEBITS    ~ALLOCBIT
  107.  
  108. #ifdef DEBUG
  109. #define MEMORY_COOKIE    5    /* When using the DEBUG option, all Malloc()
  110.                    will allocate a number of extra bytes at
  111.                    the end of the block. These will be checked
  112.                    to be intact when the block is freed or
  113.                    CheckMem()'ed. This #define tells the size
  114.                    of that block! */
  115.  
  116. #define PRE_COOKIE    5    /* Makes all allocations allocate this many
  117.                    bytes extra before the block! */
  118.  
  119. #define DEBUGPARAMETERS1 , AREG(1) char *source, DREG(2) long line
  120. #define DEBUGPARAMETERS2 , char *source, long line
  121.  
  122.  
  123. #else
  124. #define DEBUGPARAMETERS1 /* ignored! */
  125. #define DEBUGPARAMETERS2 /* ignored! */
  126. #define MEMORY_COOKIE 0
  127. #endif
  128.  
  129. /* Some bitfield defines: */
  130.  
  131. #define FPLBIT_CONDITIONAL 1 /* whether the first operator in a ?: expression
  132.                                 has been found */
  133.  
  134.  
  135. /**********************************************************************
  136.  *
  137.  * Compiler defines:
  138.  *
  139.  **********************************************************************/
  140.  
  141. #if FPL_VERSION>9
  142. #define COMPILE_AVAIL
  143. #define COMPILE(x)        GetSpecial(scr, (int)(x))
  144. #define COMPILESYMBOL(x)    GetSymbol(scr, (char *)(x))
  145. #define COMPILEINT(x)        GetInt(scr, (int)(x))
  146. #define COMPILESTRING(x)    GetString(scr, (char *)(x))
  147. #else
  148. #define COMPILE(x)
  149. #define COMPILESYMBOL(x)
  150. #define COMPILEINT(x)
  151. #define COMPILESTRING(x)
  152. #endif
  153.  
  154. typedef enum {
  155.   COMP_ERROR,    /* compiler error */
  156.   COMP_START_OF_BLOCK,
  157.   COMP_END_OF_BLOCK,
  158.   COMP_END_OF_PROGRAM,
  159.   COMP_SEMICOLON,
  160.   COMP_START_OF_CODE,
  161.   COMP_ARRAY,
  162.   COMP_COMMA,
  163.   COMP_POSTINC,
  164.   COMP_PREINC,
  165.   COMP_POSTDEC,
  166.   COMP_PREDEC,
  167.   COMP_NOT,
  168.   COMP_1COMPL,
  169.   COMP_PLUS,
  170.   COMP_MINUS,
  171.   COMP_EQUAL,
  172.  
  173.   COMP_LOGAND,
  174.   COMP_BINAND,
  175.   COMP_LOGOR,
  176.   COMP_BINOR,
  177.   COMP_BINXOR,
  178.   COMP_COND1,
  179.   COMP_COND2,
  180.   COMP_MULTIPLY,
  181.   COMP_REMAIN,
  182.   COMP_LESSEQ,
  183.   COMP_SHIFTL,
  184.   COMP_LESS,
  185.   COMP_GRETEQ,
  186.   COMP_SHIFTR,
  187.   COMP_GRET,
  188.   COMP_NOTEQUAL,
  189.   COMP_START_OF_ARRAYINFO,
  190.   COMP_END_OF_ARRAYINFO,
  191.  
  192.   COMP_START_OF_PARAMETERS,
  193.   COMP_END_OF_PARAMETERS,
  194.   COMP_START_OF_EXPR,
  195.   COMP_END_OF_EXPR,
  196.  
  197.   COMP_VARIABLEREF,
  198.  
  199.   COMP_ASSIGN,
  200.   COMP_CMPPLUS,
  201.   COMP_CMPMINUS,
  202.   COMP_CMPMUL,
  203.   COMP_CMPDIV,
  204.   COMP_CMPAND,
  205.   COMP_CMPOR,
  206.   COMP_CMPREMAIN,
  207.   COMP_CMPXOR,
  208.   COMP_CMPSHIFTL,
  209.   COMP_CMPSHIFTR,
  210.  
  211.   COMP_NO_PARAMETER,
  212.   COMP_STRING_PARAMETER,
  213.   COMP_INT_PARAMETER
  214.  
  215. } CompileCode;
  216.  
  217. /**********************************************************************
  218.  *
  219.  * Different character defines:
  220.  *
  221.  **********************************************************************/
  222.  
  223. #define END 1
  224. #define SPA 2
  225. #define LET 4
  226. #define DIG 8
  227. #define HEX 16
  228.  
  229. extern const char type[];
  230.  
  231. #define CHAR_OPEN_BRACE    '{'
  232. #define CHAR_CLOSE_BRACE   '}'
  233. #define CHAR_OPEN_PAREN    '('
  234. #define CHAR_CLOSE_PAREN   ')'
  235. #define CHAR_OPEN_BRACKET  '['
  236. #define CHAR_CLOSE_BRACKET ']'
  237. #define CHAR_COMMA         ','
  238. #define CHAR_SEMICOLON     ';'
  239. #define CHAR_PLUS          '+'
  240. #define CHAR_MINUS         '-'
  241. #define CHAR_ONCE_COMPLEMENT '~'
  242. #define CHAR_NOT_OPERATOR  '!'
  243. #define CHAR_MULTIPLY      '*'
  244. #define CHAR_DIVIDE        '/'
  245. #define CHAR_AND           '&'
  246. #define CHAR_OR            '|'
  247. #define CHAR_XOR           '^'
  248. #define CHAR_REMAIN        '%'
  249. #define CHAR_QUESTION      '?'
  250. #define CHAR_COLON         ':'
  251. #define CHAR_ASSIGN        '='
  252. #define CHAR_LESS_THAN     '<'
  253. #define CHAR_GREATER_THAN  '>'
  254. #define CHAR_SPACE         ' '
  255. #define CHAR_DOLLAR       '$'
  256. #define CHAR_HASH       '#'
  257. #define CHAR_ZERO          '0'
  258. #define CHAR_ONE           '1'
  259. #define CHAR_TWO           '2'
  260. #define CHAR_THREE         '3'
  261. #define CHAR_FOUR          '4'
  262. #define CHAR_FIVE          '5'
  263. #define CHAR_SIX           '6'
  264. #define CHAR_SEVEN         '7'
  265. #define CHAR_EIGHT         '8'
  266. #define CHAR_NINE          '9'
  267. #define CHAR_UPPER_A       'A'
  268. #define CHAR_A             'a'
  269. #define CHAR_B             'b'
  270. #define CHAR_UPPER_C       'C'
  271. #define CHAR_C             'c'
  272. #define CHAR_D             'd'
  273. #define CHAR_F             'f'
  274. #define CHAR_UPPER_I       'I'
  275. #define CHAR_I             'i'
  276. #define CHAR_UPPER_N       'N'
  277. #define CHAR_N             'n'
  278. #define CHAR_O             'o'
  279. #define CHAR_R             'r'
  280. #define CHAR_UPPER_S       'S'
  281. #define CHAR_S             's'
  282. #define CHAR_T             't'
  283. #define CHAR_V             'v'
  284. #define CHAR_UPPER_X       'X'
  285. #define CHAR_X             'x'
  286. #define CHAR_APOSTROPHE    '\''
  287. #define CHAR_NEWLINE       '\n'
  288. #define CHAR_VERTICAL_TAB  '\v'
  289. #define CHAR_CARRIAGE_RETURN '\r'
  290. #define CHAR_ALERT         '\a'
  291. #define CHAR_QUOTATION_MARK '\"'
  292. #define CHAR_BACKSLASH     '\\'
  293. #define CHAR_FORMFEED      '\f'
  294. #define CHAR_BACKSPACE     '\b'
  295. #define CHAR_TAB           '\t'
  296. #define CHAR_ASCII_ZERO    '\0'
  297.  
  298. #define CASE_BIT  32
  299.  
  300. /**********************************************************************
  301.  *
  302.  * A bunch of useful enums:
  303.  *
  304.  **********************************************************************/
  305.  
  306. typedef enum {          /* all FPL operators */
  307.   OP_NOTHING, OP_PLUS, OP_MINUS, OP_DIVISION, OP_MULTIPLY,  OP_SHIFTL,
  308.   OP_SHIFTR, OP_REMAIN, OP_BINAND, OP_BINOR, OP_BINXOR, OP_LOGAND,
  309.   OP_LOGOR, OP_COMPL, OP_COND1, OP_COND2, OP_EQUAL, OP_LESSEQ, OP_GRETEQ,
  310.   OP_LESS, OP_GRET, OP_NOTEQ, OP_NOT,
  311.  
  312.   OP_PREINC, /* pre increment */
  313.   OP_PREDEC  /* pre decrement */
  314. #ifdef NEXT_GENERATION
  315.     , OP_COMMA, OP_ASSIGN, OP_PLUSASSIGN, OP_MINUSASSIGN,
  316.     OP_ORASSIGN, OP_XORASSIGN, OP_ANDASSIGN, OP_LSHIFTASSIGN, OP_RSHIFT_ASSIGN,
  317.     OP_REMAINASIGN, OP_MULASSIGN
  318. #endif
  319.     } Operator;
  320.  
  321. typedef enum { /* the internal functions and keywords */
  322.   CMD_AUTO=-200,
  323.   CMD_BREAK,
  324.   CMD_CASE,
  325.   CMD_CONST,
  326.   CMD_CONTINUE,
  327.   CMD_DEFAULT,
  328.   CMD_DO,
  329.   CMD_DOUBLE,
  330.   CMD_ENUM,
  331.   CMD_EXIT,
  332.   CMD_EXPORT,
  333.   CMD_FLOAT,
  334.   CMD_FOR,
  335.   CMD_IF,
  336.   CMD_INT,
  337.   CMD_REGISTER,
  338.   CMD_RESIZE,
  339.   CMD_RETURN,
  340.   CMD_SIGNED,
  341.   CMD_STATIC,
  342.   CMD_STRING,
  343.   CMD_STRUCT,
  344.   CMD_SWITCH,
  345.   CMD_TYPEDEF,
  346.   CMD_UNION,
  347.   CMD_UNSIGNED,
  348.   CMD_VOID,
  349.   CMD_VOLATILE,
  350.   CMD_WHILE,
  351.  
  352.   FNC_ABS=-100,
  353.   FNC_JOINSTR,
  354.   FNC_ATOI,
  355.   FNC_EVAL,
  356.   FNC_ITOA,
  357.   FNC_ITOC,
  358.   FNC_STRCMP,
  359.   FNC_SUBSTR,
  360.   FNC_STRLEN,
  361.   FNC_STRNCMP,
  362.   FNC_STRSTR,
  363.   FNC_STRTOL,
  364.   FNC_LTOSTR,
  365.   FNC_INTERPRET,
  366.  
  367. #if defined(AMIGA)
  368.   FNC_OPENLIB,
  369.   FNC_CLOSELIB,
  370. #endif
  371.  
  372.   LAST_INTERNAL /* must be the last of these ones! */
  373.   } Funcs;
  374.  
  375. /**********************************************************************
  376.  *
  377.  * Debug macro defines.
  378.  *
  379.  *********************************************************************/
  380.  
  381. #ifdef DEBUG
  382. /* If debugging, use the mem integer to debug the MALLOC/FREE balance! */
  383. extern long mem;
  384. extern long maxmem;
  385. #endif
  386.  
  387. /**********************************************************************
  388.  *
  389.  * Script() control bits:
  390.  *
  391.  *********************************************************************/
  392.  
  393. #define SCR_NORMAL  0   /* Nothing! */
  394. #define SCR_IF      (1<<0)
  395. #define SCR_WHILE   (1<<1)
  396. #define SCR_DO      (1<<2)
  397. #define SCR_FOR     (1<<3)
  398. #define SCR_LOOP    (SCR_WHILE|SCR_DO|SCR_FOR)
  399. #define SCR_FUNCTION (1<<4)
  400. #define SCR_BRACE   (1<<5) /* Declaration is allowed! This started with a brace -
  401.                  should end with a brace, return(), break or exit()
  402.                */
  403. #define SCR_RETURN_STRING (1<<6)/* This function is declared to return a string */
  404. #define SCR_GLOBAL (1<<7)
  405. #define SCR_SWITCH (1<<8)
  406. /***********************************************************************
  407.  *
  408.  * Expression() control bits:
  409.  *
  410.  **********************************************************************/
  411.  
  412. #define CON_NORMAL     0      /* normal statement */
  413. #define CON_DECLINT    (1<<0) /* int declaration statement */
  414. #define CON_DECLSTR    (1<<1) /* string declaration statement */
  415. #define CON_GROUNDLVL  (1<<2) /* this statement starts at the ground level */
  416. #define CON_SEMICOLON  (1<<3) /* forces Statement() to return positive on ";"
  417.                  statement. Designed to support "for(;;)". */
  418. #define CON_PAREN      (1<<4) /* support for the last expression of the for(;;)
  419.                  ones */
  420. #define CON_ACTION     (1<<5) /* This flag forces Statement() to report errror
  421.                  if no "action" was made in the statement just
  422.                  parsed. */
  423. #define CON_END        (1<<6) /* Tell statement() there can be no
  424.                  "UNEXPECTED_END".*/
  425. #define CON_NUM        (1<<7) /* Only accept numerical statements! */
  426. #define CON_STRING     (1<<8) /* Hint about this being a string statement! */
  427. #define CON_DECLVOID   (1<<9) /* Declaration of a `void' function! */
  428. #define CON_DECLEXP    (1<<10) /* Declaration of an `export' symbol */
  429. #define CON_DECLGLOB   (1<<11) /* Declaration of a global symbol! */
  430. #define CON_IDENT      (1<<12) /* The local parameter points to an already
  431.                   parsed "struct Identifier" */
  432. #define CON_DECL8      (1<<13) /* Declaration of an eight bit variable */
  433. #define CON_DECL16     (1<<14) /* Declaration of an sixteen bit variable */
  434. #define CON_DECLUNSIGN (1<<15) /* Unsigned declaration */
  435. #define CON_DECLCONST  (1<<16) /* Constant declaration (read only) */
  436. #define CON_DECLSTATIC (1<<17) /* Static declaration */
  437.  
  438. #define CON_LESSTHAN32 (CON_DECL8|CON_DECL16)
  439. #define CON_DECLARE (CON_DECLINT|CON_DECLSTR|CON_DECLVOID) /* declaration */
  440.  
  441. /***********************************************************************
  442.  *
  443.  * A bunch of useful macros:
  444.  *
  445.  **********************************************************************/
  446.  
  447.   /* CALL - macro performing the instruction inside parentheses and receiving
  448.      the return code in `ret'. If `ret' happens to become non-zero, a
  449.      "return(ret);" will be performed! */
  450. #define CALL(func) if(ret=func) return(ret)
  451.  
  452.   /* GETMEM - macro allocating memory and returning FPLERR_OUT_OF_MEMORY if it
  453.      fails! */
  454.  
  455. #define GETMEM(var,size) if(!(var=(void *)MALLOC(size))) \
  456.   return(FPLERR_OUT_OF_MEMORY);
  457.  
  458.   /* GETMEMA - macro allocating static memory and returning FPLERR_OUT_OF_MEMORY
  459.      if it fails! */
  460.  
  461. #define GETMEMA(var,size) if(!(var=(void *)MALLOCA(size))) \
  462.   return(FPLERR_OUT_OF_MEMORY);
  463.  
  464.   /* STRDUP - macro instead of the common strdup() ! */
  465.  
  466. #define STRDUP(var, pointer) \
  467.   GETMEM(var, strlen((char *)(pointer))+1);\
  468.   strcpy(var, (pointer));
  469.  
  470.   /* STRDUPA - macro instead of the common strdup() for STATIC allocs ! */
  471.  
  472. #define STRDUPA(var, pointer) \
  473.   GETMEMA(var, strlen((char *)(pointer))+1);\
  474.   strcpy(var, (char *)(pointer));
  475.  
  476.  
  477.  
  478.   /* WSPACE - macro returning true if the argument character is a whitespace */
  479. #define WSPACE(x) (type[x]&SPA)
  480.  
  481.   /* WWSPACE - macro increasing the argument char pointer until it no longer
  482.      points to a WSPACE character */
  483. #define WWSPACE(x) while(WSPACE(*(x))) (x)++;
  484.  
  485.   /* NUMBER - returns true if the character argument is a valid decimal (0-9)
  486.      digit */
  487. #define NUMBER(x) (type[x]&DIG)
  488.  
  489.   /* ALPHA - returns true if the character argument is a valid character that
  490.      an identifier can start with */
  491. #define ALPHA(x) (type[x]&LET)
  492.  
  493.   /* ALPHANUM - returns true if the character argument is a valid character
  494.      or number */
  495. #define ALPHANUM(x) (type[x]&(LET|DIG))
  496.  
  497.   /* HEX - returns true if the character argument is a valid hexadecimal member
  498.      */
  499. #define HEXANUM(x) (type[x]&HEX)
  500.  
  501.   /* UPPER - returns uppercase version any a-z character */
  502. #define UPPER(x) ((x)&~CASE_BIT)
  503.  
  504.   /* ABS - returns the absolute value of the argument */
  505. #define ABS(x) ((x)>0?x:-x)
  506.  
  507.   /* MIN - returns the minimum value of the two input arguments */
  508. #define MIN(x,y) ((x)<(y)?(x):(y))
  509.  
  510.   /* MIN3 - returns the minimum value of the three input arguments */
  511. #define MIN3(x,y,z) MIN( MIN((x),(y)) ,(z))
  512.  
  513. #define ASSIGN_OPERATOR ( \
  514.              (scr->text[0]==CHAR_ASSIGN &&        \
  515.               scr->text[1]!=CHAR_ASSIGN) ||        \
  516.              ((scr->text[0]==CHAR_PLUS ||        \
  517.               scr->text[0]==CHAR_MINUS ||        \
  518.               scr->text[0]==CHAR_MULTIPLY ||    \
  519.               scr->text[0]==CHAR_DIVIDE ||        \
  520.               scr->text[0]==CHAR_AND ||        \
  521.               scr->text[0]==CHAR_OR ||        \
  522.               scr->text[0]==CHAR_REMAIN ||        \
  523.               scr->text[0]==CHAR_XOR) &&        \
  524.              scr->text[1]==CHAR_ASSIGN) ||        \
  525.              !strncmp("<<=", scr->text, 3) ||    \
  526.              !strncmp(">>=", scr->text, 3)        \
  527.             )
  528.  
  529. /***********************************************************************
  530.  *
  531.  * Defines:
  532.  *
  533.  **********************************************************************/
  534.  
  535. #define MALLOC_DYNAMIC 0
  536. #define MALLOC_STATIC  1
  537.  
  538. #ifdef DEBUG
  539. #define MALLOC(x) MallocCycle(scr, x, __FILE__, __LINE__)
  540. #define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC, __FILE__, __LINE__)
  541. #else
  542. #define MALLOC(x) MallocCycle(scr, x)
  543. #define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC)
  544. #endif
  545.  
  546. #define FREE(x) FreeCycle(scr, (void *)(x))
  547. #define FREEA(x) Free(scr, (void *)(x), MALLOC_STATIC)
  548.  
  549. #define FREEALL() FreeAll(scr, MALLOC_DYNAMIC)
  550. #define FREEALLA() FreeAll(scr, MALLOC_STATIC)
  551.  
  552. /* old version:
  553.    #define GETSTRLEN(str) ((long)*(long *)(str))
  554.    */
  555. #define GETSTRLEN(str) (((struct fplStr *)(((char *)str)-offsetof(struct fplStr, string)))->len)
  556.  
  557. #if defined(AMIGA)
  558.   /*
  559.    * We have to make all external referenced functions to receive the
  560.    * parameters in certain registers and restore the A4 register.
  561.    */
  562.  
  563. #define PREFIX __asm __saveds   /* special SAS/C ideas! Forces arguments
  564.                    to be puched in specified registers and
  565.                    forces the A6 register to be loaded at the
  566.                    beginning of the funtion. */
  567. #define AREG(x) register __a ## x
  568. #define DREG(x) register __d ## x
  569. #define REGARGS __regargs
  570. #define ASM __asm
  571.  
  572.  /***************************************
  573.   *
  574.   * funclib specific defines:
  575.   *
  576.   **************************************/
  577.  
  578. #define FPLLIB_SOURCE "FPLLIBS:"
  579. #define FPLLIB_OPENCMD "open "
  580. #define FPLLIB_CLOSECMD "close "
  581.  
  582. #else
  583.   /*
  584.    * No need for any of those!
  585.    */
  586. #define PREFIX
  587. #define REGARGS
  588. #define AREG(x)
  589. #define DREG(x)
  590. #define ASM
  591. #endif
  592.  
  593. #if defined(AMIGA) /* the amiga library defines... */
  594. #define INLINE __inline
  595. #else
  596. #define INLINE
  597. #endif
  598.  
  599. /**********************************************************************
  600.  *
  601.  * Create some structures and define their flags:
  602.  *
  603.  *********************************************************************/
  604.  
  605. struct Unary {
  606.   Operator unary;
  607.   struct Unary *next;
  608. };
  609.  
  610. struct InsideFunction {
  611.   /*
  612.    * Used for `inside' functions.
  613.    */
  614.  
  615.   char ret;
  616.   char *format; 
  617.   
  618.   long col; /* column number of the inside function position. */
  619.   long prg; /* line number of the function */
  620.   char *file; /* name of file where this function resides */
  621.   long virprg; /* virtual line number */
  622.   char *virfile; /* virtual file name */
  623. };
  624.  
  625. struct ExternalFunction {
  626.   /*
  627.    * Used for all other functions and keywords.
  628.    */
  629.   char ret; /* 'I' - returns an integer
  630.            'S' - returns a string
  631.            */
  632.   char *format; /* Parameter format. Zero terminated. Unlimited length.
  633.            'I' - integer
  634.            'S' - string
  635.            'C' - string variable structure
  636.            'N' - integer variable structure
  637.            '>' - variable number of the previous type.
  638.  
  639.            NULL pointer - no argument at all.
  640.            lower case - optional (must only be to the right of
  641.            the required)
  642.              
  643.            Ex: "ISsc"
  644.            means that the function requires two parameters:
  645.            one integer and one string. It has two optional
  646.            parameters: one string and one string variable. */
  647.   long ID; /* Identifier ID. This information is sent in the
  648.           fplArgument structure.
  649.           <0 is reserved for FPL internals. */
  650.  
  651.   void *data; /* function specific data! */
  652.   long (*func)(void *); /* optional function! */
  653. };
  654.  
  655. struct fplStr {
  656.   /*
  657.    * FPL 'string' structure!
  658.    */
  659. #ifdef STRING_STACK
  660.   char flags;      /* string controlling flags */
  661. #endif
  662.   long alloc;     /* Allocated length of following string. That goes for the
  663.              string *only*! The structure's size have to be added if
  664.              the entire alloc is wanted! Notice that the first (or
  665.              last) byte in the string belongs to the structure and
  666.              not the 'string'!!! */
  667.   long len;      /* length of following string */
  668.   char string[1]; /* memory included in the string! */
  669. };
  670.  
  671. #ifdef STRING_STACK
  672. #define FPLSTR_INSTACK 1 /* set if this string is in the string stack */
  673. #define FPLSTR_UNUSED  2 /* set when no one is using this string anymore.
  674.                             Used to determine whether to free a string that
  675.                             is to be removed from the stack. */
  676.  
  677. struct StringStack {
  678.   struct fplStr *string;
  679.   char *text;  /* interpret position of the end of string */
  680.   long prg;    /* the line number of the end of string */
  681.   long virprg; /* virtual line number of end of string */
  682. };
  683. #endif
  684.  
  685. struct fplVariable {
  686.   struct fplVariable *temp; /* Used when passing variable references. */
  687.  
  688.   long *dims;  /* An array holding the size of each dimension. */
  689.   long num;    /* Number of dimensions */
  690.   long size;   /* Number of variables in this array, that it is all
  691.           dims' members multiplied with each other! */
  692.   /*
  693.    * Variable values to read. This is an array of values if the variable
  694.    * was declared as an array!
  695.    */
  696.   union {
  697.     struct fplStr **str; /* FPL string  */
  698.     long *val32;    /* FPL integer */
  699.     short *val16;    /* FPL short   */
  700.     char *val8;        /* FPL char    */
  701.     void *val;        /* general FPL data pointer */
  702.   } var;
  703. };
  704.  
  705. struct Identifier {
  706.   /* This structure is used to store all identifiers in when they are "hashed
  707.      in". Notice that *ALL* data in this structure is pointing and referring
  708.      to the very same data as was sent to it, which means that you must keep
  709.      that data intact while using FPL. */
  710.  
  711.   char *name; /* Indentifier. Must be absolutely unique and not more than
  712.          MAX_COMMAND_LEN characters long. */
  713.  
  714.   union {
  715.     struct ExternalFunction external;
  716.     struct InsideFunction inside;
  717.     struct fplVariable variable;
  718.   } data;
  719.   
  720.   unsigned long flags; /* See below! */
  721.  
  722.   char *file;    /* file name of the file in which we find this identifier
  723.            0 if exported global */
  724.   
  725.   struct Identifier *func; /* It exists only under this function. Pointer might
  726.                   be NULL if in no-name function! */
  727.  
  728.   long level; /* In which level this exists.
  729.          Variables exist in all levels below (with a higher number)
  730.          where it was declared. Two declarations using the same
  731.          name in the same level is not allowed!
  732.          LONG_MAX if global! */
  733.   
  734.   unsigned long hash; /* Hash value. To get the proper hash table entry for
  735.              this, use [hash%HASH_TABLE_SIZE] */
  736.   
  737.   /* Bidirectional links to keep a hash value sorted order among
  738.      functions using the same hash table entry: */
  739.   struct Identifier *prev;
  740.   struct Identifier *next;
  741. };
  742.  
  743. /****** Identifier.flags defines:  ******/
  744.  
  745. /* Data type */
  746.  
  747. #define FPL_STRING_VARIABLE   (1<<0)  /* string variable */
  748. #define FPL_INT_VARIABLE      (1<<1)  /* integer variable */
  749. #define FPL_COPIED_DATA       (1<<2)  /* identifier reference */
  750. #define FPL_INTERNAL_FUNCTION (1<<3)  /* internal FPL function */
  751. #define FPL_EXTERNAL_FUNCTION (1<<4)  /* user supplied external function */
  752. #define FPL_INSIDE_FUNCTION   (1<<5)  /* inside function in any program */
  753. #define FPL_KEYWORD          (1<<10) /* this is a keyword identifier! */
  754. #define FPL_KEYWORD_DECLARE   (1<<11) /* declaring keyword */
  755. #define FPL_INSIDE_NOTFOUND   (1<<15) /* This inside function has not been
  756.                      discovered yet. The position the
  757.                      data points to is the search start
  758.                      position. */
  759. #define FPL_IGNORE            (1<<17) /* Read this and then drop it! */
  760. /* Data status */
  761.  
  762. #define FPL_READONLY          (1<<6)  /* const variable! */
  763. #define FPL_HIJACKED_VARIABLE (1<<7)  /* hijacked variable! */
  764. #define FPL_EXPORT_SYMBOL     (1<<8)  /* cross program accessible */
  765. #define FPL_GLOBAL_SYMBOL     (1<<9)  /* global accessible in one file */
  766. #define FPL_SHORT_VARIABLE    (1<<12) /* short (16-bit) variable */
  767. #define FPL_CHAR_VARIABLE     (1<<13) /* char (8-bit) variable */
  768. #define FPL_UNSIGNED_VARIABLE (1<<14) /* unsigned variable */
  769. #define FPL_STATIC_VARIABLE   (1<<16) /* static variable! */
  770.  
  771.  
  772. #define FPL_NONGLOBAL          (1<<17) /* delete global status! */
  773.  
  774. #define FPL_STATUS (FPL_READONLY|FPL_HIJACKED_VARIABLE|FPL_EXPORT_SYMBOL\
  775.             FPL_GLOBAL_SYMBOL|FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE\
  776.             FPL_UNSIGNED_VARIABLE|FPL_STATIC_VARIABLE|FPL_NONGLOBAL)
  777.  
  778. /*
  779.  * These two lower flags should be combined with the "Data status" flags
  780.  * when declaring variables!
  781.  */
  782.  
  783. #define FPLDECL_STRING          (1<<31) /* Keyword declaring string */
  784. #define FPLDEC_INT          (1<<30) /* Keyword declaring int */
  785.  
  786.  
  787. #define FPL_VARIABLE_LESS32 (FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE)
  788. #define FPL_VARIABLE (FPL_STRING_VARIABLE|FPL_INT_VARIABLE)
  789. #define FPL_FUNCTION (FPL_INTERNAL_FUNCTION|FPL_EXTERNAL_FUNCTION |\
  790.               FPL_INSIDE_FUNCTION)
  791.  
  792. /***** Identifier.ID defines: ******/
  793.  
  794. #define FPL_INSIDE_FUNCTION_ID -3;
  795.  
  796. struct Condition {
  797.   char *bracetext;  /* pointer to the character to the right of the open
  798.                brace */
  799.   long braceprg;    /* line number of the above data */
  800.   char *check;      /* pointer to the expression. Used by while() and for() */
  801.   long checkl;      /* the line number of the expression */
  802.   char *postexpr;   /* USED BY "for" : pointer to statement3 */
  803.   long postexprl;   /* USED BY "for" : statement3's line number */
  804. };
  805.  
  806. struct Expr {  /* the numerical expression linked list */
  807.   union {
  808.     long val;        /* numerical return */
  809.     struct fplStr *str; /* string return */
  810.   } val;
  811.   Operator operator;  /* see the operator enums! */
  812.   struct Unary *unary; /* unary/primary operators linked list! */
  813.   short flags;          /* see below */
  814.   struct Expr *next; 
  815. };
  816.  
  817. /**** struct Expr.flags defines: ****/
  818. #define FPL_STRING     (1<<0) /* Expr structure is a string. */
  819. #define FPL_NOFREE     (1<<1) /* A returned string should not be freed */
  820. #define FPL_OPERAND    (1<<2) /* Next part in the expression is a operand */
  821. #define FPL_ACTION     (1<<3) /* The expression includes any variable change(s) */
  822. #define FPL_BREAK      (1<<4) /* The val member specifies number of levels
  823.                  left to break from! */
  824. #define FPL_RETURN     (1<<5) /* There is a return call received, return to the
  825.                  last function caller. */
  826. #define FPL_CONTINUE   (1<<6) /* Continue is flagged! */
  827.  
  828. #define FPL_DEFUNCTION (1<<7) /* The Expression() just called declared AND
  829.                  defined a function! */
  830. #define FPL_BRACE      (1<<8) /* This invoke returned due to a closing brace! */
  831.  
  832. struct Local {
  833.   /*
  834.    * This structure will create a linked list of all local variables declared
  835.    * in this level. When leaving this level, *ALL* variables with the names
  836.    * that the ->ident member points to must be deleted, using DelIdentifier().
  837.    */
  838.   struct Identifier *ident;
  839.         /* This pointer points to the Identifier structure,
  840.            that means this should *NOT* be freed individually
  841.            but only the entire structure and the Identifier structure
  842.            (and members) at the same time! */
  843.   struct Local *next; /* Next member in this chain */
  844. };
  845.  
  846. /*
  847.  * All fplFunction ID's below zero are reserved for FPL internal use.
  848.  * We use the funcdata member to set some flags:
  849.  */
  850. #define FPL_HASH_INSIDE   1
  851. #define FPL_HASH_INTERNAL 2
  852.  
  853. struct Program {
  854.   struct Program *next;
  855.   char *name;        /* unique name of program */
  856.   long running;        /* true if running */
  857.   long openings;    /* number of invokes! */
  858.   char *program;    /* program pointer or NULL if not present in memory */
  859.   long lines;        /* number of lines */
  860.   long size;        /* total size in number of bytes */
  861.   long flags;        /* see defines below */
  862.  
  863.   long startcol;    /* Where "main" started. Column number */
  864.   long startprg;    /* Where "main" started. Line number */
  865.   long virprg;        /* Virtual line number of "main" */
  866.   char *virfile;    /* virtual file name of "main" */
  867.   long column;        /* Last interpreted column!
  868.                _ONLY_ to read if this program isn't opened! */
  869. #ifdef AMIGA
  870.   void *lock;        /* if using the FPLTAG_LOCKUSED, this is the lock of
  871.                this particular file! */
  872. #endif
  873.   long warnings;    /* number of warnings found in this file! */
  874.  
  875. #ifdef STRING_STACK
  876.   long strings_in_stack_max;
  877.   long strings_in_stack_now;
  878.   long stringstackptr;
  879.   struct StringStack **stringstack;
  880. #endif
  881.  
  882. };
  883.  
  884. /* Program.flags: */
  885. #define PR_USERSUPPLIED 1
  886. /* This program is user supplied. That means that FPL has *not* allocated the
  887.    memory this program uses, making no straight flushes allowed! */
  888.  
  889. #define PR_CACHEFILE 2
  890. /* This program should be cached until anything else is said! */
  891.  
  892. #define PR_FILENAMEFLUSH 4
  893. /* When this program is flushed, it can always be restored by using the
  894.    program name as file name to read from! */
  895.  
  896. #define PR_TEMPORARY 8
  897. /* This isn't a real program but only created for a temporary usage reason! */
  898.  
  899. #define PR_GLOBALSTORED 16
  900. /* This program has got it's global symbols stored! */
  901.  
  902. #define PR_CACHEEXPORTS 32
  903. /* This program should be cached only if exports are declared */
  904.  
  905. struct FuncList {
  906.   /*
  907.    * This struct is a general purpose linked list struct for keeping track
  908.    * of a list of char pointers.
  909.    */
  910.   struct FuncList *next;
  911.   long opens;
  912.   unsigned char flags;
  913.   char *name;
  914. };
  915.  
  916. struct Store {
  917.   /*
  918.    * This is all data that should be backuped when recursing, and
  919.    * restored when the recursing function ends.
  920.    */
  921.   char *text;
  922.   long prg;
  923.   char strret;
  924.   long level;
  925.   long varlevel;
  926.   char *virfile;
  927.   long virprg;
  928.   char *interpret;
  929.   struct Local *globals;
  930.   struct fplMsg *msg;
  931.   struct Program *prog;
  932.   struct Local *locals;
  933. };
  934.  
  935. struct Data {
  936.   /*
  937.    * Allocated at fplInit() and freed at fplFree().
  938.    */
  939. #ifdef AMIGA
  940.   char *stack_base;    /* our new stack base */
  941.   long stack_size;    /* requested stack size! */
  942.   long stack_max;    /* Maximum stack left after a FPL function call */
  943.   long stack_limit;    /* absolute maximum stack usage allowed */
  944.   long stack_margin;    /* minimum stack required to call the interface
  945.                function! */
  946.   long registers[11];    /* Storage for the eleven registers that should be
  947.                brought back when calling the interface function */
  948. #endif
  949.   /* --------------------------------------------------------------------- */
  950.   /* If anything is changed among the above, check validity of liballoc.i! */
  951.   /* --------------------------------------------------------------------- */
  952.  
  953.   void * ASM (*Alloc)(DREG(0) long);  /* allocate routine to use */
  954.   void ASM (*Dealloc)(AREG(1) void *, DREG(0) long); /* dealloc routine */
  955.  
  956.   long ASM (*function) (AREG(0) void *); /* Pointer to function handler. */
  957.   long ASM (*interfunc) (AREG(0) void *); /* Function to be called every now
  958.                          and then when executing, enabling
  959.                          your programming to keep track of
  960.                          different things even if FPL is in
  961.                          charge! */
  962.   long ASM (*newline_hook)(AREG(0) void *); /* Newline hook function pointer */ 
  963.  
  964.   /********* START OF STORE STRUCT ***********/
  965.   
  966.   char *text;       /* Current interpret position */
  967.   long prg;         /* Current line number */
  968.  
  969.   char strret;        /* The Script() now executing should return a
  970.                string! (TRUE/FALSE) */
  971.   long level;        /* Nesting level */
  972.   long varlevel;    /* current variable level */
  973.  
  974.   char *virfile;    /* virtual file name occurred! */
  975.   long virprg;        /* virtual line number */
  976.  
  977.   char *interpret;  /* if we whould interpret anything else but the main
  978.                function! Set this with the FPLTAG_INTERPRET tag. */
  979.  
  980.   struct Local *globals; /* Pointer to list holding all global symbols
  981.                 currently declared in this program. They might be
  982.                 removed when this program quits if the user has
  983.                 set that flag or if we miss certain information */
  984.  
  985.   struct fplMsg *msg; /* Pointer to any pending message to FPL sent from the
  986.              user. We expect return codes from user functions to
  987.              be sent using this. */
  988.  
  989.   struct Program *prog; /* Pointer to the "struct Program" holding information
  990.                about the program we're currently interpreting */
  991.  
  992.   struct Local *locals; /* Linked list of local variables! If any error
  993.                code is returned, there might be local variables
  994.                left to free in any precious local level! Use this
  995.                list to delete 'em all!
  996.                
  997.                We add *ALL* levels to one list, separated with a
  998.                NULL name. Deleting only the latest level, deletes
  999.                to the nearest NULL name!
  1000.                */
  1001.  
  1002.   /********* END OF STORE STRUCT *************/
  1003.  
  1004.   struct Program *programs; /* list with all files information */
  1005.   long ret;        /* Return value of the FPL block */
  1006.   char *buf;        /* Global buffer pointer (Why use more than one buffer
  1007.                at a time? It's only a waste of valuable stack!) */
  1008.   void *userdata;       /* Global Userdata. Free to use. */
  1009.   unsigned char flags;  /* Flags. See defines below! */
  1010.   long data;            /* The result of the interfunc. */
  1011.   long FPLret;            /* FPL return code = the result of the
  1012.                "exit(RETURN_CODE);" call! */
  1013.   long hash_size;    /* hash table size! */
  1014.   struct Identifier **hash;  /* Must be set to NULL before doing anything
  1015.                 major... like using fplAddFunction() or
  1016.                 calling fplExecute[File]() The NULL-setting is
  1017.                 done by fplInit(). */
  1018.  
  1019.   struct Local *usersym; /* Pointer to list holding all global symbols
  1020.                 declared in another FPL program run. These symbols
  1021.                 are legal global symbols */
  1022.   
  1023.   struct MemInfo *MallocKey[2]; /* We have two mallockey pointers because we
  1024.                    have two different kinds of Malloc()s! One
  1025.                    for each execution and one for each
  1026.                    fplInit(). */
  1027.   struct FreeBlock *blox[BLOCK_ENTRIES]; /* memory caching tables */
  1028.   long blockcount[BLOCK_ENTRIES]; /* memory caching table counters */
  1029.   struct Identifier *func; /* pointer to the current interpreted function
  1030.                   or NULL */
  1031.   long runs;
  1032.   char **string_return;  /* whether this program should allow strings to be
  1033.                 returned to the host program (set with the
  1034.                 FPLTAG_STRING_RETURN tag to 'fplExecuteXXX()'). */
  1035.   char compiling; /* TRUE if compiling!!! */
  1036. #if defined(AMIGA)
  1037.   struct FuncList *funclibs; /* a linked list with the current opened funclib
  1038.                                 names */
  1039. #endif
  1040. };
  1041.  
  1042. /***** Data.flags: *****/
  1043.  
  1044. #define FPLDATA_ALLFUNCTIONS (1<<0)
  1045. /* Accept all functions, even if not found! */
  1046.  
  1047. #define FPLDATA_CACHEFILE (1<<1)
  1048. /* This file should be cached among the other global data. */
  1049.  
  1050. #define FPLDATA_CACHEALLFILES (1<<2)
  1051. /* This makes FPL store all files in memory that it has to remember */
  1052.  
  1053. #define FPLDATA_CACHEEXPORTS (1<<3)
  1054. /* This makes FPL store all files in memory that exports symbols */
  1055.  
  1056. #define FPLDATA_LOCKUSED (1<<5)
  1057. /* Lock() the current files! */
  1058.  
  1059. #define FPLDATA_NESTED_COMMENTS (1<<6)
  1060. /* Allow nested comments */
  1061.  
  1062. struct fplMsg {
  1063.   struct fplMsg *next;  /* next message struct */
  1064.   struct fplMsg *prev;    /* when priority is allowed, things might be inserted
  1065.                virtually anywhere in the list */
  1066.   char type;        /* type of message. See defined below! */
  1067.   void *message[4];    /* different meanings depending on the type */
  1068. };
  1069.  
  1070. #define FPLMSG_RETURN_INT     1 /* message[0] is a long integer */
  1071. #define FPLMSG_RETURN_STRING  2 /* message[0] is the FPL-type string */
  1072. #define FPLMSG_STOP          3 /* message[0] is to be stored in Data->data
  1073.                    as the "result of the last interfunc". */
  1074. #define FPLMSG_PROGRAM          4 /* message[0] is a (char **) to the program
  1075.                    array, message[1] is zero or the new number
  1076.                    of lines and message[2] is zero or the new
  1077.                    program size. */
  1078. #define FPLMSG_CONFIRM          5 /* message[0] is TRUE/FALSE */
  1079. #define FPLMSG_GLOBAL          6 /* Global symbol reading is ordered.
  1080.                    (FPLSEND_GLOBALSYMBOLS)
  1081.                    message[0] holds the current pointer to a
  1082.                    struct Local */
  1083.  
  1084.  
  1085. /**********************************************************************
  1086.  *                                                                    *
  1087.  * All functions used from external functions.                        *
  1088.  *                                                                    *
  1089.  **********************************************************************/
  1090.  
  1091. ReturnCode PREFIX fplExecuteScript(AREG(0) struct Data *,
  1092.                    AREG(1) char **,
  1093.                    DREG(1) long,
  1094.                    AREG(2) unsigned long *);
  1095. ReturnCode PREFIX fplExecuteFile(AREG(0) struct Data *,
  1096.                  AREG(1) char *,
  1097.                  AREG(2) unsigned long *);
  1098. char * PREFIX fplGetErrorMsg(AREG(0) struct Data *,
  1099.                  DREG(0) long,
  1100.                  AREG(1) char *);
  1101. void * ASM fplInit(AREG(0) long (*)(void *),
  1102.            AREG(1) unsigned long *);
  1103. void PREFIX fplFree(AREG(0) void *);
  1104. ReturnCode PREFIX fplAddFunction(AREG(0) struct Data *,
  1105.                  AREG(1) char *,
  1106.                  DREG(0) long,
  1107.                  DREG(1) char,
  1108.                  AREG(2) char *,
  1109.                  AREG(3) unsigned long *);
  1110. ReturnCode PREFIX fplDelFunction(AREG(0) struct Data *,
  1111.                  AREG(1) char *);
  1112. ReturnCode PREFIX fplReset(AREG(0) struct Data *,
  1113.                AREG(1) unsigned long *);
  1114. ReturnCode PREFIX fplSend(AREG(0) struct Data *,
  1115.               AREG(1) unsigned long *);
  1116. void PREFIX *fplAlloc(AREG(0) struct Data *,
  1117.               DREG(0) long);
  1118. void PREFIX fplDealloc(AREG(0) struct Data *,
  1119.                AREG(1) void *);
  1120. void PREFIX *fplAlloca(AREG(0) struct Data *,
  1121.                DREG(0) long);
  1122. void PREFIX fplDealloca(AREG(0) struct Data *,
  1123.                 AREG(1) void *);
  1124. long PREFIX fplConvertString(AREG(0) struct Data *,
  1125.                  AREG(1) char *,
  1126.                  AREG(2) char *);
  1127. ReturnCode PREFIX fplCallFunction(AREG(0) struct Data *,
  1128.                   AREG(1) char *,
  1129.                   DREG(0) long,
  1130.                   AREG(2) void **,
  1131.                   AREG(3) char *format,
  1132.                   AREG(4) unsigned long *);
  1133.  
  1134. void PREFIX *fplAllocString(AREG(0) struct Data *,
  1135.                 DREG(0) long);
  1136. void PREFIX fplFreeString(AREG(0) struct Data *,
  1137.               AREG(1) void *);
  1138.  
  1139. #ifdef AMIGA
  1140. long PREFIX fplOpenLib(AREG(0) struct Data *,
  1141.                        AREG(1) char *,
  1142.                        DREG(0) long,
  1143.                        DREG(1) long);
  1144. long PREFIX fplCloseLib(AREG(0) struct Data *,
  1145.                         AREG(1) char *,
  1146.                         DREG(0) long);
  1147. #endif
  1148.  
  1149. #ifdef HIJACK
  1150. ReturnCode PREFIX fplHijack(AREG(0) struct Data *,
  1151.                 AREG(1) char *);
  1152. #endif
  1153.  
  1154. /**********************************************************************
  1155.  * All functions used globally in the library.                        *
  1156.  **********************************************************************/
  1157. ReturnCode Script(struct Data *, struct Expr *, short, struct Condition *);
  1158. ReturnCode  Expression(struct Expr *, struct Data *, long, struct Identifier *);
  1159. ReturnCode  Eat(struct Data *);
  1160. ReturnCode  Getword(char *, struct Data *);
  1161.  
  1162. #ifdef UNIX
  1163. long InterfaceCall(struct Data *, void *, long (*)(void *));
  1164. /* The Amiga version has this function coded in assembler */
  1165. #endif
  1166.  
  1167. ReturnCode  DelProgram(struct Data *, struct Program *);
  1168. ReturnCode  ReadFile(void *, char *, struct Program *);
  1169. ReturnCode  Newline(struct Data *);
  1170. long  Strtol(char *, long, char **);
  1171.  
  1172. ReturnCode  NewMember(struct Data *, struct Expr **);
  1173. ReturnCode  AddVar(struct Data *, struct Identifier *, struct Local **);
  1174. ReturnCode  ReturnChar(struct Data *, long *, char);
  1175. ReturnCode  GetEnd(struct Data *, char, char, char);
  1176. ReturnCode  CmpAssign(struct Data *, long, long *, long, char);
  1177. ReturnCode  StrAssign(struct fplStr *, struct Data *, struct fplStr **, char);
  1178.  
  1179. ReturnCode  GetProgram(struct Data *, struct Program *);
  1180. ReturnCode  LeaveProgram(struct Data *, struct Program *);
  1181. ReturnCode  Warn(struct Data *, ReturnCode);
  1182.  
  1183. ReturnCode  DeleteMessage(struct Data *, struct fplMsg *);
  1184. ReturnCode  GetMessage(struct Data *, char, struct fplMsg **);
  1185. ReturnCode  functions(struct fplArgument *);
  1186.  
  1187. ReturnCode  GetIdentifier(struct Data *, char *, struct Identifier **);
  1188. ReturnCode  DelIdentifier(struct Data *, char *, struct Identifier *);
  1189. void ASM *DefaultAlloc(DREG(0) long);
  1190. void ASM DefaultDealloc(AREG(1) void *, DREG(0) long);
  1191. ReturnCode  DelLocalVar(struct Data *, struct Local **);
  1192. ReturnCode  AddLevel(struct Data *);
  1193.  
  1194. void  SwapMem(struct Data *, void *, char);
  1195. void ASM Free(AREG(0) struct Data *, AREG(1) void *, DREG(0) char);
  1196. void  FreeCycle(struct Data *, void *);
  1197. void  FreeAll(struct Data *, char);
  1198. void ASM *Malloc(AREG(0) struct Data *, DREG(0) long, DREG(1) char DEBUGPARAMETERS1);
  1199. void  *MallocCycle(struct Data *, long DEBUGPARAMETERS2);
  1200. void  InitFree(struct Data *);
  1201. void  FlushFree(struct Data *);
  1202. void  CleanUp(struct Data *, long, long);
  1203. #ifdef DEBUG
  1204. ReturnCode  CheckMem(struct Data *, void *);
  1205. #endif
  1206.  
  1207. #if defined(AMIGA)
  1208.  /*
  1209.   * These are functions for funclibs only:
  1210.   */
  1211.  
  1212. ReturnCode REGARGS OpenLib(struct Data *, char *, long, long *, char);
  1213. ReturnCode REGARGS CloseLib(struct Data *,  char *, long, long *);
  1214.  
  1215. #endif
  1216. /*************
  1217.   Compile prototypes!
  1218. **************/
  1219.  
  1220. ReturnCode  GetString(struct Data *, char *);
  1221. ReturnCode  GetSymbol(struct Data *, char *);
  1222. ReturnCode  GetInt(struct Data *, int);
  1223. ReturnCode  GetSpecial(struct Data *, CompileCode);
  1224.  
  1225.